import {
  Body,
  Controller,
  Get,
  Param,
  ParseIntPipe,
  Post,
  Put,
} from '@nestjs/common';
import { wrapperResponse } from 'src/utils';
import { MenuService } from './menu.service';

@Controller('menu')
export class MenuController {
  constructor(private readonly menuService: MenuService) {}

  // @Get(':id')
  // getMenu(@Param('id', ParseIntPipe) id: number) {
  //   console.log(typeof id);
  //   return this.menuService.findOne(id);
  // }

  @Get()
  getAllMenu() {
    return wrapperResponse(this.menuService.findAll(), '获取所有菜单成功');
  }

  @Get('active')
  getActiveMenu() {
    return wrapperResponse(this.menuService.findActive(), '获取启用菜单成功');
  }

  @Get(':id')
  getMenu(@Param('id', ParseIntPipe) id: number) {
    console.log('id: ', id);
  }

  @Post()
  create(@Body() body) {
    return this.menuService.create(body);
  }

  @Put()
  update(@Body() body) {
    return this.menuService.update(body);
  }

  // @Delete(':id')
  // remove(@Param('id', ParseIntPipe) id: number) {
  //   return this.menuService.remove(id);
  // }
}
